package pack0706.com;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class UserManager {
    //用户管理类
    static List list = new ArrayList();

    //创建一个Scanner 对象
    private static Scanner scan = new Scanner(System.in);

    //用户的注册
    public static void register() {
        System.out.println("请输入用户名: ");
        String name = scan.next();

        System.out.println("请输入密码: ");
        String pass = "";
        while (true) {
            pass = scan.next();
            if (pass.length() < 3 || pass.length() > 6) {
                System.out.println("密码长度必须在3-6位之间,请重新输入 ");
            } else
                break;
        }
        System.out.println("请确认密码: ");
        String repass = scan.next();
        //如果两次密码不一致,则注册失败
        if (!repass.equals(pass)) {
            System.out.println("两次密码不一致,注册失败");
            //退出方法
            return;
        }

        //用户名和密码都没问题
        String id = Tools.getNewId();

        //封装数据
        User user = new User(id, name, pass);

        //将用户存放到集合中
        //需要知道用户存放的位置
        list.add(user);
        System.out.println("恭喜你注册成功,账号是:" + id + ",下次登录使用");
    }
        //用户的登录
        public static boolean login () {
            System.out.println("请输入账号: ");
            String id = scan.next();
            System.out.println("请输入密码: ");
            String pass = scan.next();
            return true;
        }




}
